package com.hhxy.service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Request&Response初体验
 */
@WebServlet("/ReTest")
public class ReTest extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1、使用Request对象获取请求数据
        String name = req.getParameter("name");//url?name=zhansan
        //2、使用Response对象设置响应数据
        resp.setHeader("content-type","text/html;charset=utf-8");//设置响应头的编码格式
        resp.getWriter().write("<h1>"+name+",欢迎您！</h1>");//返回的响应数据
    }
}
